﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UtilityExtensions;
namespace UILGestion.Control
{
    public partial class ECItemElimReAgrupadoPanel : System.Web.UI.UserControl
    {
        public event EventHandler DataBound;
        public ListView ListView
        {

            get { return ListView1; }

        }


        public List<int> SeleccionList
        {
            get
            {
                // Create a List to hold the EmployeeID values to delete
                List<Int32> idLista = new List<Int32>();

                // Iterate through the Employees.Rows property
                foreach (ListViewDataItem row in ListView1.Items)
                {

                    // Access the CheckBox
                    CheckBox cb = (CheckBox)(row.FindControl("chkEmployeeSelector"));
                    if (cb != null && cb.Checked)
                    {
                        // Save the EmployeeID value for deletion
                        // First, get the EmployeeID for the selected row
                        
                        int idInternal = int.Parse(ListView1.DataKeys[row.DisplayIndex][0].ToString());

                        idLista.Add(idInternal);
                    }
                }
                return idLista;
            }
        }

        public int pagesize { get { return Util.GetPageSizeCookie(); } }
        protected void Page_Load(object sender, EventArgs e)
        {
            pager.PageSize = 5;

        }

        

        public override void DataBind()
        {
            ListView1.DataBind();
        }
        public string DataSourceID
        {
            set { ListView1.DataSourceID = value; }
        }
        public object DataSource
        {
            set { ListView1.DataSource = value; }
        }

       

        public int TopRolId
        {
            get { return (int)ListView1.DataKeys[0].Value; }
        }

        protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                var link = e.Item.FindControl("HyperLink1") as HyperLink;
                var r = e.Item as ListViewDataItem;
                // var d = r.DataItem as OrdenCompraListInfo;
                //link.NavigateUrl ="javascript:PageMethods.ToggleTag({0},'{1}',ToggleTagCallback)".Fmt(d.idInternal, link.ClientID);


            }

        }
        protected void ListView1_DataBound(object sender, EventArgs e)
        {
            if (DataBound != null)
                DataBound(sender, e);
        }
    }
}